﻿<%@ Page Title="" Language="VB" MasterPageFile="~/Library/Site.master" AutoEventWireup="false"
    CodeFile="Usuarios.aspx.vb" Inherits="Administracion_Usuarios" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <h1>
        USUARIOS
    </h1>
    <asp:Button ID="btnNuevo" runat="server" Text="Nuevo usuario" CssClass="boton" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>    
    <asp:Panel ID="pnlRegistrarUsuario" runat="server" Visible="False">
        <table>
            <tr>
                <th colspan="2">
                    Agregar Usuario
                    <asp:HiddenField ID="hdIdusuario" runat="server" Value="0"/>
                </th>
            </tr>
            <tr>
                <td>
                    Nombres
                </td>
                <td>
                    <asp:TextBox ID="txtNombre" runat="server" MaxLength='40'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                        ControlToValidate="txtNombre" CssClass="error" ErrorMessage="Obligatorio" Display = "Dynamic" ></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Apellidos
                </td>
                <td>
                    <asp:TextBox ID="txtApellido" runat="server" MaxLength='40'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                        ControlToValidate="txtApellido" CssClass="error" ErrorMessage="Obligatorio" Display = "Dynamic" ></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Correo Electrónico
                </td>
                <td>
                    <asp:TextBox ID="txtEmail" runat="server" MaxLength='100'></asp:TextBox>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                        ControlToValidate="txtEmail" CssClass="error" Display="Dynamic" 
                        ErrorMessage="Correo no válido" 
                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Usuario
                </td>
                <td>
                    <asp:TextBox ID="txtUsuario" runat="server" MaxLength='20'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                        ControlToValidate="txtUsuario" CssClass="error" ErrorMessage="Obligatorio" Display = "Dynamic" ></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Clave
                </td>
                <td>
                    <asp:TextBox ID="txtClave"  runat="server" MaxLength='20'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                        ControlToValidate="txtClave" CssClass="error" ErrorMessage="Obligatorio" Display = "Dynamic" ></asp:RequiredFieldValidator>
                    <cc1:PasswordStrength ID="PasswordStrength2" runat="server" TargetControlID="txtClave"
            DisplayPosition="RightSide" 
            StrengthIndicatorType="BarIndicator"
            PreferredPasswordLength="10"
            HelpStatusLabelID="TextBox2_HelpLabel"
            
            StrengthStyles="BarIndicator_TextBox2_weak;BarIndicator_TextBox2_average;BarIndicator_TextBox2_good"
            
            BarBorderCssClass="BarBorder_TextBox2"
            MinimumNumericCharacters="1"
            MinimumSymbolCharacters="1"
            TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"
            RequiresUpperAndLowerCaseCharacters="true" >
                    </cc1:PasswordStrength>
                </td>
            </tr>
            <tr>
                <td>
                    Perfil
                </td>
                <td>
                    <asp:DropDownList ID="ddlPerfil" runat="server">
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                        ControlToValidate="ddlPerfil" CssClass="error" ErrorMessage="Obligatorio" Display = "Dynamic" ></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Operador</td>
                <td>
                    <asp:DropDownList ID="ddlOperador" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    Activo
                </td>
                <td>
                    <asp:DropDownList ID="ddlActivo" runat="server">
                        <asp:ListItem Value="1" Selected ="True">Sí</asp:ListItem>
                        <asp:ListItem Value="0">No</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="botones">
                    <asp:CustomValidator ID="CustomValidator1" runat="server" CssClass="error"></asp:CustomValidator>
                    <asp:Button ID="btnGuardar" runat="server" Text="Guardar" CssClass="boton" />
                    &nbsp;&nbsp;
                    <asp:Button ID="btnCancelar" runat="server" Text="Cancelar" CssClass="boton" CausesValidation="false"  />
                </td>
            </tr>
        </table>
    </asp:Panel>
    </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnNuevo" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>

    <h1>
        Usuarios registrados</h1>
    <asp:GridView ID="grdUsuarios" runat="server" AutoGenerateColumns="False" DataKeyNames ="IdUsurio">
        <Columns>
            <asp:BoundField DataField="nombre" HeaderText="Operador" />
            <asp:BoundField DataField="Usuario" HeaderText="Usuario" />
            <asp:BoundField DataField="Nombres" HeaderText="Nombres" />
            <asp:BoundField DataField="Apellidos" HeaderText="Apellido" />
            <asp:BoundField DataField="Perfil" HeaderText="Perfil" />
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="lnkEditar" runat="server" CausesValidation="False" CommandName="Editar" CommandArgument='<%#Eval("IdUsurio") %>'
                        Text="Editar"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Eliminar" CommandArgument='<%#Eval("IdUsurio") %>'
                        Text="Eliminar"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
</asp:Content>
